home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.8 KB | 81 lines | [TEXT/CWIE] |
- // RegionObject.h
-
- #ifndef RegionObject_h
- #define RegionObject_h
-
- #ifndef Rectangle_h
- #include "Rectangle.h"
- #endif
-
- class RegionObject
- {
- private:
- RgnHandle me;
-
- static RegionObject& Temporary( const Rect& );
- static RegionObject& Temporary( RgnHandle );
-
- public:
- RegionObject();
- RegionObject( RgnHandle );
- RegionObject( const RegionObject& );
- RegionObject( const Rect& );
-
- ~RegionObject() { DisposeRgn( me ); }
-
- void BeEmpty() { SetEmptyRgn( me ); }
-
- void operator=( const Rect& r ) { RectRgn( me, &r ); }
- void operator=( RgnHandle r ) { CopyRgn( r, me ); }
- void operator=( const RegionObject& r ) { CopyRgn( r, me ); }
-
- void operator&=( const Rect& r );
- void operator|=( const Rect& r );
- void operator^=( const Rect& r );
- void operator-=( const Rect& r );
- void Complement( const Rect& r );
-
- void operator&=( RgnHandle r ) { SectRgn( me, r, me ); }
- void operator|=( RgnHandle r ) { UnionRgn( me, r, me ); }
- void operator^=( RgnHandle r ) { XorRgn( me, r, me ); }
- void operator-=( RgnHandle r ) { DiffRgn( me, r, me ); }
- void Complement( RgnHandle r ) { DiffRgn( r, me, me ); }
-
- void operator+=( Point vector ) { OffsetRgn( me, vector.h, vector.v ); }
- void operator-=( Point vector ) { OffsetRgn( me, -vector.h, -vector.v ); }
-
- void Inset( int16 amount ) { InsetRgn( me, amount, amount ); }
- void Inset( Point amount ) { InsetRgn( me, amount.h, amount.v ); }
- void Outset( int16 amount ) { InsetRgn( me, -amount, -amount ); }
- void Outset( Point amount ) { InsetRgn( me, -amount.h, -amount.v ); }
-
- void GlobalToLocal();
- void LocalToGlobal();
-
- Rectangle Bounds() const { return (*me)->rgnBBox; }
- operator RgnHandle() const { return me; }
-
- bool IsEmpty() const { return EmptyRgn( me ); }
- bool Contains( Point p ) const { return PtInRgn( p, me ); }
- bool Rectangular() const { return (*me)->rgnSize == 10; }
-
- bool Intersects( const Rect& r ) const;
- bool Intersects( const RgnHandle r ) const;
-
- bool operator==( const Rect& r ) const;
- bool operator!=( const Rect& r ) const { return !(*this == r); }
- bool operator<=( const Rect& r ) const;
- bool operator>=( const Rect& r ) const;
- bool operator<( const Rect& r ) const { return *this <= r && *this != r; }
- bool operator>( const Rect& r ) const { return *this >= r && *this != r; }
-
- bool operator==( RgnHandle r ) const { return EqualRgn( me, r ); }
- bool operator!=( RgnHandle r ) const { return !EqualRgn( me, r ); }
- bool operator<=( RgnHandle r ) const;
- bool operator>=( RgnHandle r ) const;
- bool operator<( RgnHandle r ) const { return *this <= r && *this != r; }
- bool operator>( RgnHandle r ) const { return *this >= r && *this != r; }
- };
-
- #endif
-